home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / DIHDRWRT.C < prev    next >
C/C++ Source or Header  |  1995-07-29  |  2KB  |  77 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    dihdrwrt.c
  5. //   Title:    Data File I/O Library
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //
  24. //    This module contains code to write a data file header.
  25. //
  26. //    The code in this module should be written entirely in C. 
  27. //    Do not use any C++ constructs.
  28. //
  29. //    This module is portable to:
  30. //        DOS 3.X+
  31. //        MS Windows 3.X+
  32. //        OS/2 2.X+
  33. //        OS/2 2.0 PM
  34. //        SCO UNIX.
  35. //
  36. //    The following compilers are supported:
  37. //        MSC 6.0A
  38. //        MSC/C++ 7.0
  39. //        Borland C++ 3.1 for DOS
  40. //        Borland C++ 1.0 for OS/2 2.X
  41. //        SCO UNIX cc
  42. //
  43. //----------------------------------------------------------------------------
  44. #include <di.h>
  45.  
  46.  
  47. //----------------------------------------------------------------------------
  48. //   Description:    Write file header of a data file given the table offset.
  49. //    Parameters:    hpf        Physical file handle
  50. //                        phdr        Buffer to read header into.
  51. //       Returns:    TRUE if successful.
  52. //----------------------------------------------------------------------------
  53. BOOL FN_E DioHeaderWrite(HPF hpf, PDATAHDR phdr)
  54. {
  55.     time_t now = time(NULL);
  56.  
  57.     Assert(phdr);
  58.     Assert(hpf >= 0 && hpf < MAX_PHYSICAL_FILES);
  59.     Assert(di.physical[hpf].fUsed);
  60.     Assert(di.physical[hpf].fWriteable);
  61.  
  62.     if (di.physical[hpf].fl & PF_ERROR)    // Check for file error
  63.         return FALSE;
  64.  
  65.     phdr->timetModified = now;                // Update modify time and CRC
  66.     phdr->crc = (ULONG)CrcCalc((PBYTE)phdr, sizeof(DATAHDR) - sizeof(ULONG));
  67.     if (!FileWrite(di.physical[hpf].hf, phdr, sizeof(DATAHDR), 0L))
  68.         {
  69.         di.physical[hpf].fl |= PF_ERROR;
  70.         return FALSE;
  71.         }
  72.     return TRUE;
  73. }
  74. //----------------------------------------------------------------------------
  75. //------------------------------- End of File --------------------------------
  76. //----------------------------------------------------------------------------
  77.